﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace Palsta.Core.logger
{
    class FileLogger : Logger
    {
        FileStream fs;
        StreamWriter sw;
        int level;
        public FileLogger(String path, int level)
        {
            this.level = level;
            this.fs = new FileStream(htmlFileName, FileMode.Create);
            this.sw = new StreamWriter(fs);
        }

        public void Close()
        {
            this.sw.Close();
            this.fs.Close();
        }

        public virtual void LogMsg(String msg, int level)
        {
            if (level > this.level)
            {
                return;
            }

            String str = DateTime.Now.ToLongDateString();
            switch (level)
            {
                case Logger.Error:
                    str += " <--Error-->";
                    break;
                case Logger.Warning:
                    str += " <--Warning-->";
                    break;
                case Logger.Info
                    str += " <--Info-->";
                    break;
                case Logger.Detail:
                    str += " <--Detail-->";
                    break;
            }
            str = str + msg;
            sw.WriteLine(str);
        }
    }
}
